#region Apache License
//
// Licensed to the Apache Software Foundation (ASF) under one or more 
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership. 
// The ASF licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with 
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion



using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;

namespace IPSim.GUI.Devices
{
    public class SwitchDevice : PictureDevice
    {
        #region Members


        #endregion

        #region Methods

        public SwitchDevice(int top, int left): base(top, left, Properties.Resources.switch64)
        {
            InitConnectors();
        }

        protected void InitConnectors()
        {
            connectors.Add(new ConnectorDevice(this));
            connectors.Add(new ConnectorDevice(this));
            connectors.Add(new ConnectorDevice(this));
            connectors.Add(new ConnectorDevice(this));
            UpdateConnectorsPosition();
        }

        internal override void UpdateConnectorsPosition()
        {
            Point loc;
            ConnectorDevice connector;

            //Top
            loc = new Point(this.location.X + this.size.Width / 2,
                this.location.Y + Convert.ToInt32(this.size.Height * 0.34));
            connector = (ConnectorDevice)connectors[0];
            connector.Location = new Point(loc.X - connectorSize, loc.Y - connectorSize);
            connector.Size = new Size(connectorSize * 2, connectorSize * 2);

            //Bottom
            loc = new Point(this.location.X + this.size.Width / 2,
                this.location.Y + Convert.ToInt32(this.size.Height * 0.85));
            connector = (ConnectorDevice)connectors[1];
            connector.Location = new Point(loc.X - connectorSize, loc.Y - connectorSize);
            connector.Size = new Size(connectorSize * 2, connectorSize * 2);

            //Left
            loc = new Point(this.location.X + Convert.ToInt32(this.size.Width * 0.08),
                this.location.Y + Convert.ToInt32(this.size.Height * 0.6));
            connector = (ConnectorDevice)connectors[2];
            connector.Location = new Point(loc.X - connectorSize, loc.Y - connectorSize);
            connector.Size = new Size(connectorSize * 2, connectorSize * 2);

            //Right
            loc = new Point(this.location.X + Convert.ToInt32(this.size.Width * 0.92),
                this.location.Y + Convert.ToInt32(this.size.Height * 0.6));
            connector = (ConnectorDevice)connectors[3];
            connector.Location = new Point(loc.X - connectorSize, loc.Y - connectorSize);
            connector.Size = new Size(connectorSize * 2, connectorSize * 2);

        }

        #endregion

        #region Properties

        [Category("Power")]
        [Browsable(true)]
        [Description("Device Power - ON/OFF")]
        public bool PoweredOn
        {
            get
            {
                return false;
            }
        }

        #endregion

        #region Events


        #endregion
    }
}
